package com.core.system.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.common.annotation.LogInfo;
import com.core.system.domain.Apicode;
import com.core.system.dto.ApicodeDto;
import com.core.system.service.ApicodeService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;

@RestController
@RequestMapping("/admin/apicode")
@Api(value = "后台apicode控制层",tags = {"后台apicode控制层"})
@LogInfo
public class ApicodeController {

    @Autowired
    private ApicodeService apicodeService;

    /**
     * 查询所有记录
     *
     */
    @ApiOperation("查询apicode分页记录接口")
    @PreAuthorize("hasAnyAuthority(@servletUtils.getUrl)")
    @GetMapping("/list")
    public ResponseEntity list(Page pageDto,Apicode apicode ) {
        return apicodeService.list(pageDto,apicode);
    }

     
    /**
     * 新增，忽略null字段
     *@param apicode 新增的记录
     *
     */
    @ApiOperation("保存或更新apicode记录接口")
    @PreAuthorize("hasAnyAuthority(@servletUtils.getUrl)")
    @PostMapping("/save")
    public ResponseEntity save(@Valid @RequestBody ApicodeDto apicode) {
        return apicodeService.save(apicode);
    }    

    /**
     * 批量删除
     * @param ids
     * 
     */
    @ApiOperation("批量删除apicode记录接口")
    @PreAuthorize("hasAnyAuthority(@servletUtils.getUrl)")
    @DeleteMapping("/del")
    public ResponseEntity delAll(@RequestBody List<Long> ids) {
        return apicodeService.delAll(ids);
    }
    
}